# Contributor: knuxify <knuxify@gmail.com>
# Maintainer: knuxify <knuxify@gmail.com>
pkgname=libopenmpt
pkgver=0.7.6
pkgrel=0
pkgdesc="Cross-platform library to render tracker music to a PCM audio stream"
url="https://lib.openmpt.org/libopenmpt/"
arch="all"
license="BSD-3-Clause"
makedepends="flac-dev libogg-dev pulseaudio-dev libsndfile-dev libvorbis-dev mpg123-dev portaudio-dev zlib-dev"
subpackages="$pkgname-dev openmpt123:_openmpt123 openmpt123-doc:_openmpt123_doc"
source="https://lib.openmpt.org/files/libopenmpt/src/libopenmpt-$pkgver+release.autotools.tar.gz"
builddir="$srcdir/libopenmpt-$pkgver+release.autotools"

prepare() {
	default_prepare
	# Drop +release.autotools suffix from version number; otherwise pkgconf
	# files don't pass abuild's requirements
	sed -i 's/+release.autotools//' "$builddir"/configure
}

build() {
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-static
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	# just a readme and license and example .c
	rm -r "$pkgdir"/usr/share/doc
}

_openmpt123() {
	pkgdesc="Command-line module file player"
	amove usr/bin/openmpt123
}

_openmpt123_doc() {
	default_doc
	install_if="openmpt123=$pkgver-r$pkgrel docs"
}

sha512sums="
9665d3e301bab06f363bc4376fc488ca5befcf05f580deeb01a035167f02f8d47cda0d940239d5f29a91f97da6f31a2f6f20836b4f8ef6a248c7e39e49a7aa66  libopenmpt-0.7.6+release.autotools.tar.gz
"
